
<!DOCTYPE html>
<html >
<head >
    <title></title> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="./styles/webreaderDemo.css" />
    <link rel="stylesheet" type="text/css" href="./styles/dialog.css" />
</head>
<body>

    <div class="wrap">
        <div class="top">
        	<div class="langsel"><a href="WebReaderDemo.jsp" style="color:white">Back Home page</a></div>
        </div>
        <div class="rdbanner"><img src="./images/xg/banner.png"/></div>
        <div id='content'>
			<div class="rdcontent uploadContent">
                    <div style="margin-bottom:50px;margin-top:30px"><span class="fontweight">Function Option:</span>
                        <div style="margin-top:6px" id="plugins">
                            <input id="annot" type="checkbox" value="0x0001" name="annot">Annotation&nbsp;&nbsp;&nbsp;
                            <input id="findtool" type="checkbox" value="0x0002" name="findtool">Find&nbsp;&nbsp;&nbsp;
                            <!-- <input id="navigation" type="checkbox"  onclick="onclicknav();" value="navigation" name="navigation"/>NavigationPanel&nbsp&nbsp&nbsp -->
                            <input id="thumbnail" type="checkbox" value="0x0008" name="thumbnail">Thumbnail&nbsp;&nbsp;&nbsp;
                            <input id="bookmark" type="checkbox" value="0x0010" name="bookmark">Bookmark&nbsp;&nbsp;&nbsp;
                            <input id="docproperties" type="checkbox" value="0x0020" name="docproperties">Properties&nbsp;&nbsp;&nbsp;
                            <input id="toolbar" type="checkbox" value="0x0040" name="toolbar">ToolBar&nbsp;&nbsp;&nbsp;
                            <input id="menu" type="checkbox" value="0x0080" name="menu">Menu&nbsp;&nbsp;&nbsp;
                            <input id="form" type="checkbox" value="0x0100" name="form">Form&nbsp;&nbsp;&nbsp;
                        </div>
                    </div>
                    <button type="button" style='float:right;margin-right:30px;' id="SaveConfig" class="button orange">Save the configuration</button>
            </div>
         </div>
         <div class="rdfooter"><div style="padding-top:8px;">©2012 Foxit Corporation. All rights reserved.</div></div>
    </div>
</body>

<script type="text/javascript" src="./Scripts/jquery.1.4.2.js"></script>
<script type="text/javascript" src="./Scripts/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="./Scripts/fxformdlg.js"></script>
<script type="text/javascript">
function QueryString(key) {
       return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
 }
 
 $(document).ready(function () {
 	 InitDlgHelper();
	 GetConfigFromServer();
	 $("#SaveConfig").click(function(){
		 SaveConfig();
	 });
 });
 
 var pluginFlag = {
     Annot: 0x0001,
     FindTool: 0x0002,
     NavigationPanel: 0x0004,
     Thumbnail: 0x0008,
     Bookmark: 0x0010,
     DocProperties: 0x0020,
     ToolBar: 0x0040,
     Menu: 0x0080,
     Form: 0x0100
 };
 

 function GetConfigFromServer()
 {
		 $.ajax({
             url: 'GetBackstagePluginConfig.do',
             type: 'POST',
             dataType: 'json',
             data: "",

             success: function (response) {
            	 if(response==null || response.error =="-1")
            	 {
            		 g_DlgHelper.alert("Web Reader", "The user does not exist,Please login!");
            		 window.location.href ="./login.htm";
            		 return;
            	 }
            	 if(response==null || response.pluginsConfig == null)
            		 g_DlgHelper.alert("Web Reader", "Failed to get configuration information!");
                 var pluginConfig = parseInt(response.pluginsConfig);
                 if(pluginConfig & pluginFlag.Annot)
                 {
                	 $("#annot").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.FindTool)
                 {
                	 $("#findtool").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.Thumbnail)
                 {
                	 $("#thumbnail").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.Bookmark)
                 {
                	 $("#bookmark").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.DocProperties)
                 {
                	 $("#docproperties").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.ToolBar)
                 {
                	 $("#toolbar").attr("checked", 'true');
                 }
				 if(pluginConfig & pluginFlag.Menu)
                 {
                	 $("#menu").attr("checked", 'true');
                 }
                 if(pluginConfig & pluginFlag.Form)
                 {
                	 $("#form").attr("checked", 'true');
                 }
             },
             error: function (XMLHttpRequest, textStatus, errorThrown) {
            	 g_DlgHelper.alert("Web Reader", "Failed to get configuration information!");
             }
         });
	 
		 
 }
 
 function SaveConfig()
 {
	var user = document.getElementById("userid").value;
	 
	var jqPluginConfig = $("#plugins");
	if(jqPluginConfig == null)
	{
		g_DlgHelper.alert("Web Reader", "Failed to save the configuration information!");
		return;
	}
	var jqPlugins = jqPluginConfig.children();
	var pluginConfig = 0x0000;
	for(var i=0;i< jqPlugins.length;i++){
		var j22 = jqPlugins[i];
		if(jqPlugins[i].checked)
		{
			var pluginValue = parseInt($(jqPlugins[i]).attr("value"));;
			pluginConfig |= pluginValue;
		}

	}
	var data = {pluginConfig:pluginConfig,user:user};
	$.ajax({
             url: 'SavePluginConfig.do',
             type: 'POST',
             dataType: 'json',
             data: data,

             success: function (response) {
            	 if(response==null || response.error =="-1")
            	 {
            		 g_DlgHelper.alert("Web Reader", "The user does not exist,Please login!");
            		 window.location.href ="./login.htm";
            		 return;
            	 }
				if(response!=null && response.error!=null && response.error==0)
					g_DlgHelper.alert("Web Reader", "Save the configuration information was successfully!");
				else
					g_DlgHelper.alert("Web Reader", "Failed to save the configuration information!");
			 },
             error: function (XMLHttpRequest, textStatus, errorThrown) {
            	 g_DlgHelper.alert("Web Reader", "Failed to save the configuration information!");
             }
    });
 }
</script>


</html>